using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using PickGold.Charting.Utilities;
using PickGold.Charting.Design;

namespace PickGold.Charting
{
	[DefaultProperty("Name")]
	[SRDescription("DescriptionAttributeAnnotation_Annotation")]
	[AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
	[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
	public abstract class Annotation : ChartNamedElement, IChartMapArea
	{
		private ContentAlignment _alignment = ContentAlignment.MiddleCenter;
		private DataPoint _anchorDataPoint;
		private DataPoint _anchorDataPoint2;
		private string _anchorDataPointName = string.Empty;
		private double _anchorX = double.NaN;
		private double _anchorY = double.NaN;
		private Axis _axisX;
		private string _axisXName = string.Empty;
		private Axis _axisY;
		private string _axisYName = string.Empty;
		private Color _backColor = Color.Empty;
		private GradientStyle _backGradientStyle;
		private ChartHatchStyle _backHatchStyle;
		private Color _backSecondaryColor = Color.Empty;
		private string _clipToChartArea = "NotSet";
		private FontCache _fontCache = new FontCache();
		private Color _foreColor = Color.Black;
		private double _height = double.NaN;
		private bool _isSelected;
		private bool _isSizeAlwaysRelative = true;
		private ChartDashStyle _lineDashStyle = ChartDashStyle.Solid;
		private int _lineWidth = 1;
		private string _mapAreaAttributes = string.Empty;
		private string _postbackValue = string.Empty;
		private Color _shadowColor = Color.FromArgb(0x80, 0, 0, 0);
		private int _shadowOffset;
		private AnnotationSmartLabelStyle _smartLabelStyle;
		private System.Drawing.Font _textFont;
		private TextStyle _textStyle;
		private string _tooltip = string.Empty;
		private string _url = string.Empty;
		private bool _visible = true;
		private double _width = double.NaN;
		private double _x = double.NaN;
		private double _y = double.NaN;
		internal ContentAlignment anchorAlignment = ContentAlignment.BottomCenter;
		internal double anchorOffsetX;
		internal double anchorOffsetY;
		internal AnnotationGroup annotationGroup;
		internal PointF currentAnchorLocationRel = new PointF(float.NaN, float.NaN);
		internal int currentPathPointIndex = -1;
		internal RectangleF currentPositionRel = new RectangleF(float.NaN, float.NaN, float.NaN, float.NaN);
		internal Color lineColor = Color.Black;
		internal const int selectionMarkerSize = 6;
		internal RectangleF[] selectionRects;
		internal GraphicsPath startMovePathRel;
		internal RectangleF startMovePositionRel = RectangleF.Empty;
		internal static double WidthHightLimit = 290000000.0;

		protected Annotation()
		{
			this._textFont = this._fontCache.DefaultFont;
		}

		internal void AddSmartLabelMarkerPositions(ArrayList list)
		{
			if (this.Visible && this.IsAnchorDrawn())
			{
				Axis vertAxis = null;
				Axis horizAxis = null;
				this.GetAxes(ref vertAxis, ref horizAxis);
				double naN = double.NaN;
				double anchorY = double.NaN;
				bool inRelativeAnchorX = false;
				bool inRelativeAnchorY = false;
				this.GetAnchorLocation(ref naN, ref anchorY, ref inRelativeAnchorX, ref inRelativeAnchorY);
				if (!double.IsNaN(naN) && !double.IsNaN(anchorY))
				{
					if (!inRelativeAnchorX && (horizAxis != null))
					{
						naN = horizAxis.ValueToPosition(naN);
					}
					if (!inRelativeAnchorY && (vertAxis != null))
					{
						anchorY = vertAxis.ValueToPosition(anchorY);
					}
					ChartArea chartArea = null;
					if ((horizAxis != null) && (horizAxis.ChartArea != null))
					{
						chartArea = horizAxis.ChartArea;
					}
					if ((vertAxis != null) && (vertAxis.ChartArea != null))
					{
						chartArea = vertAxis.ChartArea;
					}
					if ((((chartArea != null) && chartArea.Area3DStyle.Enable3D) && (!chartArea.chartAreaIsCurcular && chartArea.requireAxes)) && chartArea.matrix3D.IsInitialized())
					{
						float areaSceneDepth = chartArea.areaSceneDepth;
						if ((this.AnchorDataPoint != null) && (this.AnchorDataPoint.series != null))
						{
							float depth = 0f;
							chartArea.GetSeriesZPositionAndDepth(this.AnchorDataPoint.series, out depth, out areaSceneDepth);
							areaSceneDepth += depth / 2f;
						}
						Point3D[] points = new Point3D[] { new Point3D((float)naN, (float)anchorY, areaSceneDepth) };
						chartArea.matrix3D.TransformPoints(points);
						naN = points[0].X;
						anchorY = points[0].Y;
					}
					if (this.GetGraphics() != null)
					{
						SizeF relativeSize = this.GetGraphics().GetRelativeSize(new SizeF(1f, 1f));
						RectangleF ef2 = new RectangleF(((float)naN) - (relativeSize.Width / 2f), ((float)anchorY) - (relativeSize.Height / 2f), relativeSize.Width, relativeSize.Height);
						list.Add(ef2);
					}
				}
			}
		}

		internal virtual void AdjustLocationSize(SizeF movingDistance, ResizingMode resizeMode)
		{
			this.AdjustLocationSize(movingDistance, resizeMode, true);
		}

		internal virtual void AdjustLocationSize(SizeF movingDistance, ResizingMode resizeMode, bool pixelCoord)
		{
			this.AdjustLocationSize(movingDistance, resizeMode, pixelCoord, false);
		}

		internal virtual void AdjustLocationSize(SizeF movingDistance, ResizingMode resizeMode, bool pixelCoord, bool userInput)
		{
			if (!movingDistance.IsEmpty)
			{
				if (pixelCoord)
				{
					movingDistance = base.Chart.ChartPicture.ChartGraph.GetRelativeSize(movingDistance);
				}
				PointF empty = PointF.Empty;
				PointF anchorLocation = PointF.Empty;
				SizeF size = SizeF.Empty;
				if (userInput)
				{
					this.GetRelativePosition(out empty, out size, out anchorLocation);
				}
				else
				{
					this.GetRelativePosition(out empty, out size, out anchorLocation);
				}
				new PointF(empty.X + size.Width, empty.Y + size.Height);
				if (resizeMode == ResizingMode.TopLeftHandle)
				{
					empty.X -= movingDistance.Width;
					empty.Y -= movingDistance.Height;
					size.Width += movingDistance.Width;
					size.Height += movingDistance.Height;
				}
				else if (resizeMode == ResizingMode.TopHandle)
				{
					empty.Y -= movingDistance.Height;
					size.Height += movingDistance.Height;
				}
				else if (resizeMode == ResizingMode.TopRightHandle)
				{
					empty.Y -= movingDistance.Height;
					size.Width -= movingDistance.Width;
					size.Height += movingDistance.Height;
				}
				else if (resizeMode == ResizingMode.RightHandle)
				{
					size.Width -= movingDistance.Width;
				}
				else if (resizeMode == ResizingMode.BottomRightHandle)
				{
					size.Width -= movingDistance.Width;
					size.Height -= movingDistance.Height;
				}
				else if (resizeMode == ResizingMode.BottomHandle)
				{
					size.Height -= movingDistance.Height;
				}
				else if (resizeMode == ResizingMode.BottomLeftHandle)
				{
					empty.X -= movingDistance.Width;
					size.Width += movingDistance.Width;
					size.Height -= movingDistance.Height;
				}
				else if (resizeMode == ResizingMode.LeftHandle)
				{
					empty.X -= movingDistance.Width;
					size.Width += movingDistance.Width;
				}
				else if (resizeMode == ResizingMode.AnchorHandle)
				{
					anchorLocation.X -= movingDistance.Width;
					anchorLocation.Y -= movingDistance.Height;
				}
				else if (resizeMode == ResizingMode.Moving)
				{
					empty.X -= movingDistance.Width;
					empty.Y -= movingDistance.Height;
				}
				if (resizeMode == ResizingMode.Moving)
				{
					if (double.IsNaN(this.Width))
					{
						size.Width = float.NaN;
					}
					if (double.IsNaN(this.Height))
					{
						size.Height = float.NaN;
					}
				}
				if (resizeMode == ResizingMode.AnchorHandle)
				{
					if (double.IsNaN(this.X))
					{
						empty.X = float.NaN;
					}
					if (double.IsNaN(this.Y))
					{
						empty.Y = float.NaN;
					}
				}
				else if (double.IsNaN(this.AnchorX) || double.IsNaN(this.AnchorY))
				{
					anchorLocation = new PointF(float.NaN, float.NaN);
				}
				this.SetPositionRelative(new RectangleF(empty, size), anchorLocation, userInput);
			}
		}

		public virtual void BringToFront()
		{
			AnnotationCollection annotations = null;
			if (base.Chart != null)
				annotations = base.Chart.Annotations;
			var annotationGroup = this.AnnotationGroup;
			if (annotationGroup != null)
				annotations = annotationGroup.Annotations;
			if (annotations != null)
			{
				var item = annotations.FindByName(this.Name);
				if (item != null)
				{
					annotations.Remove(item);
					annotations.Add(this);
				}
			}
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing && (this._fontCache != null))
			{
				this._fontCache.Dispose();
				this._fontCache = null;
			}
			base.Dispose(disposing);
		}

		private void GetAnchorLocation(ref double anchorX, ref double anchorY, ref bool inRelativeAnchorX, ref bool inRelativeAnchorY)
		{
			anchorX = this.AnchorX;
			anchorY = this.AnchorY;
			if (((this.AnchorDataPoint != null) && (this.AnchorDataPoint.series != null)) && ((base.Chart != null) && (base.Chart.ChartPicture != null)))
			{
				if (this.AnnotationGroup != null)
					throw new InvalidOperationException(SR.ExceptionAnnotationGroupedAnchorDataPointMustBeEmpty);

				if (double.IsNaN(anchorX) || double.IsNaN(anchorY))
				{
					if (double.IsNaN(anchorX))
					{
						anchorX = this.AnchorDataPoint.positionRel.X;
						inRelativeAnchorX = true;
					}
					if (double.IsNaN(anchorY))
					{
						anchorY = this.AnchorDataPoint.positionRel.Y;
						inRelativeAnchorY = true;
					}
				}
			}
		}

		internal void GetAxes(ref Axis vertAxis, ref Axis horizAxis)
		{
			vertAxis = null;
			horizAxis = null;
			if ((this.AxisX != null) && (this.AxisX.ChartArea != null))
			{
				if (this.AxisX.ChartArea.switchValueAxes)
				{
					vertAxis = this.AxisX;
				}
				else
				{
					horizAxis = this.AxisX;
				}
			}
			if ((this.AxisY != null) && (this.AxisY.ChartArea != null))
			{
				if (this.AxisY.ChartArea.switchValueAxes)
				{
					horizAxis = this.AxisY;
				}
				else
				{
					vertAxis = this.AxisY;
				}
			}
			if (this.AnchorDataPoint != null)
			{
				if (horizAxis == null)
				{
					horizAxis = this.GetDataPointAxis(this.AnchorDataPoint, AxisName.X);
					if (((horizAxis != null) && (horizAxis.ChartArea != null)) && horizAxis.ChartArea.switchValueAxes)
					{
						horizAxis = this.GetDataPointAxis(this.AnchorDataPoint, AxisName.Y);
					}
				}
				if (vertAxis == null)
				{
					vertAxis = this.GetDataPointAxis(this.AnchorDataPoint, AxisName.Y);
					if (((vertAxis != null) && (vertAxis.ChartArea != null)) && vertAxis.ChartArea.switchValueAxes)
					{
						vertAxis = this.GetDataPointAxis(this.AnchorDataPoint, AxisName.X);
					}
				}
			}
			if (((vertAxis != null) || (horizAxis != null)) && (this.AnnotationGroup != null))
				throw new InvalidOperationException(SR.ExceptionAnnotationGroupedAxisMustBeEmpty);
		}

		private Axis GetAxisByName(string axisName)
		{
			Axis axis = null;
			try
			{
				if ((base.Chart != null) && (axisName.Length > 0))
				{
					int index = axisName.IndexOf(@"\r", StringComparison.Ordinal);
					if (index > 0)
					{
						string str = axisName.Substring(0, index);
						string str2 = axisName.Substring(index + 2);
						switch (((AxisName)Enum.Parse(typeof(AxisName), str2)))
						{
							case AxisName.X:
								return base.Chart.ChartAreas[str].AxisX;

							case AxisName.Y:
								return base.Chart.ChartAreas[str].AxisY;

							case AxisName.X2:
								return base.Chart.ChartAreas[str].AxisX2;

							case AxisName.Y2:
								return base.Chart.ChartAreas[str].AxisY2;
						}
					}
				}
			}
			catch (ArgumentNullException)
			{
				axis = null;
			}
			catch (ArgumentException)
			{
				axis = null;
			}
			return axis;
		}

		private string GetAxisName(Axis axis)
		{
			string str = string.Empty;
			if (axis.ChartArea != null)
			{
				str = axis.ChartArea.Name + @"\r" + axis.AxisName.ToString();
			}
			return str;
		}

		internal virtual RectangleF GetContentPosition()
		{
			return new RectangleF(float.NaN, float.NaN, float.NaN, float.NaN);
		}

		private Axis GetDataPointAxis(DataPoint dataPoint, AxisName axisName)
		{
			if (((dataPoint == null) || (dataPoint.series == null)) || (base.Chart == null))
			{
				return null;
			}
			ChartArea area = base.Chart.ChartAreas[dataPoint.series.ChartArea];
			if (((axisName == AxisName.X) || (axisName == AxisName.X2)) && !area.switchValueAxes)
			{
				return area.GetAxis(axisName, dataPoint.series.XAxisType, dataPoint.series.XSubAxisName);
			}
			return area.GetAxis(axisName, dataPoint.series.YAxisType, dataPoint.series.YSubAxisName);
		}

		internal DataPoint GetDataPointByName(string dataPointName)
		{
			DataPoint point = null;
			if ((base.Chart != null) && (dataPointName.Length > 0))
			{
				int index = dataPointName.IndexOf(@"\r", StringComparison.Ordinal);
				if (index > 0)
				{
					int num2;
					string str = dataPointName.Substring(0, index);
					if (int.TryParse(dataPointName.Substring(index + 2), NumberStyles.Any, CultureInfo.InvariantCulture, out num2))
					{
						point = base.Chart.Series[str].Points[num2];
					}
				}
			}
			return point;
		}

		internal string GetDataPointName(DataPoint dataPoint)
		{
			string str = string.Empty;
			if (dataPoint.series != null)
			{
				int index = dataPoint.series.Points.IndexOf(dataPoint);
				if (index >= 0)
				{
					str = dataPoint.series.Name + @"\r" + index.ToString(CultureInfo.InvariantCulture);
				}
			}
			return str;
		}

		internal ChartGraphics GetGraphics()
		{
			if (base.Common != null)
			{
				return base.Common.graph;
			}
			return null;
		}

		internal virtual void GetRelativePosition(out PointF location, out SizeF size, out PointF anchorLocation)
		{
			bool flag = true;
			if (!double.IsNaN((double)this.currentPositionRel.X) && !double.IsNaN((double)this.currentPositionRel.X))
			{
				location = this.currentPositionRel.Location;
				size = this.currentPositionRel.Size;
				anchorLocation = this.currentAnchorLocationRel;
				return;
			}
			Axis vertAxis = null;
			Axis horizAxis = null;
			this.GetAxes(ref vertAxis, ref horizAxis);
			if ((this._anchorDataPoint != null) && (this._anchorDataPoint2 != null))
			{
				this.IsSizeAlwaysRelative = false;
				this.Height = vertAxis.PositionToValue((double)this._anchorDataPoint2.positionRel.Y, false) - vertAxis.PositionToValue((double)this._anchorDataPoint.positionRel.Y, false);
				this.Width = horizAxis.PositionToValue((double)this._anchorDataPoint2.positionRel.X, false) - horizAxis.PositionToValue((double)this._anchorDataPoint.positionRel.X, false);
				this._anchorDataPoint2 = null;
			}
			var flag2 = false;
			var flag3 = false;
			var flag4 = this._isSizeAlwaysRelative;
			var flag5 = this._isSizeAlwaysRelative;
			var inRelativeAnchorX = false;
			var inRelativeAnchorY = false;
			var anchorX = this.AnchorX;
			var anchorY = this.AnchorY;
			this.GetAnchorLocation(ref anchorX, ref anchorY, ref inRelativeAnchorX, ref inRelativeAnchorY);
			var annotationGroup = this.AnnotationGroup;
			var empty = PointF.Empty;
			var num3 = 1.0D;
			var num4 = 1.0D;
			if (annotationGroup != null)
			{
				var ef = SizeF.Empty;
				var tf2 = PointF.Empty;
				flag = false;
				annotationGroup.GetRelativePosition(out empty, out ef, out tf2);
				num3 = ef.Width / 100.0D;
				num4 = ef.Height / 100.0D;
			}
			var d = this._width;
			var height = this._height;
			var contentPosition = this.GetContentPosition();
			if (double.IsNaN(d))
			{
				d = contentPosition.Width;
				flag4 = true;
			}
			else
			{
				d *= num3;
			}
			if (double.IsNaN(height))
			{
				height = contentPosition.Height;
				flag5 = true;
			}
			else
			{
				height *= num4;
			}
			if (((base.Chart != null) && base.Chart.IsDesignMode()) && (this.IsSizeAlwaysRelative || ((vertAxis == null) && (horizAxis == null))))
			{
				if (double.IsNaN(d))
				{
					d = 20.0;
					flag = false;
				}
				if (double.IsNaN(height))
				{
					height = 20.0;
					flag = false;
				}
			}
			double x = this.X;
			double y = this.Y;
			if (double.IsNaN(y) && !double.IsNaN(anchorY))
			{
				flag3 = true;
				double num9 = anchorY;
				if (!inRelativeAnchorY && (vertAxis != null))
				{
					num9 = vertAxis.ValueToPosition(anchorY);
				}
				if (((this.AnchorAlignment == ContentAlignment.TopCenter) || (this.AnchorAlignment == ContentAlignment.TopLeft)) || (this.AnchorAlignment == ContentAlignment.TopRight))
				{
					y = num9 + this.AnchorOffsetY;
					y *= num4;
				}
				else if (((this.AnchorAlignment == ContentAlignment.BottomCenter) || (this.AnchorAlignment == ContentAlignment.BottomLeft)) || (this.AnchorAlignment == ContentAlignment.BottomRight))
				{
					y = num9 - this.AnchorOffsetY;
					y *= num4;
					if ((height != 0.0) && !double.IsNaN(height))
					{
						if (flag5)
						{
							y -= height;
						}
						else if (vertAxis != null)
						{
							float num10 = (float)vertAxis.PositionToValue(y);
							float num11 = (float)vertAxis.ValueToPosition(num10 + height);
							y -= num11 - y;
						}
					}
				}
				else
				{
					y = num9 + this.AnchorOffsetY;
					y *= num4;
					if ((height != 0.0) && !double.IsNaN(height))
					{
						if (flag5)
						{
							y -= height / 2.0;
						}
						else if (vertAxis != null)
						{
							float num12 = (float)vertAxis.PositionToValue(y);
							float num13 = (float)vertAxis.ValueToPosition(num12 + height);
							y -= (num13 - y) / 2.0;
						}
					}
				}
			}
			else
			{
				y *= num4;
			}
			if (double.IsNaN(x) && !double.IsNaN(anchorX))
			{
				flag2 = true;
				double num14 = anchorX;
				if (!inRelativeAnchorX && (horizAxis != null))
				{
					num14 = horizAxis.ValueToPosition(anchorX);
				}
				if (((this.AnchorAlignment == ContentAlignment.BottomLeft) || (this.AnchorAlignment == ContentAlignment.MiddleLeft)) || (this.AnchorAlignment == ContentAlignment.TopLeft))
				{
					x = num14 + this.AnchorOffsetX;
					x *= num3;
				}
				else if (((this.AnchorAlignment == ContentAlignment.BottomRight) || (this.AnchorAlignment == ContentAlignment.MiddleRight)) || (this.AnchorAlignment == ContentAlignment.TopRight))
				{
					x = num14 - this.AnchorOffsetX;
					x *= num3;
					if ((d != 0.0) && !double.IsNaN(d))
					{
						if (flag4)
						{
							x -= d;
						}
						else if (horizAxis != null)
						{
							float num15 = (float)horizAxis.PositionToValue(x);
							x -= horizAxis.ValueToPosition(num15 + d) - x;
						}
					}
				}
				else
				{
					x = num14 + this.AnchorOffsetX;
					x *= num3;
					if ((d != 0.0) && !double.IsNaN(d))
					{
						if (flag4)
						{
							x -= d / 2.0;
						}
						else if (horizAxis != null)
						{
							float num16 = (float)horizAxis.PositionToValue(x);
							x -= (horizAxis.ValueToPosition(num16 + d) - x) / 2.0;
						}
					}
				}
			}
			else
			{
				x *= num3;
			}
			x += empty.X;
			y += empty.Y;
			if (double.IsNaN(x))
			{
				x = contentPosition.X * num3;
				flag2 = true;
			}
			if (double.IsNaN(y))
			{
				y = contentPosition.Y * num4;
				flag3 = true;
			}
			if (horizAxis != null)
			{
				if (!flag2)
				{
					x = horizAxis.ValueToPosition(x);
				}
				if (!inRelativeAnchorX)
				{
					anchorX = horizAxis.ValueToPosition(anchorX);
				}
				if (!flag4)
				{
					d = horizAxis.ValueToPosition(horizAxis.PositionToValue(x, false) + d) - x;
				}
			}
			if (vertAxis != null)
			{
				if (!flag3)
				{
					y = vertAxis.ValueToPosition(y);
				}
				if (!inRelativeAnchorY)
				{
					anchorY = vertAxis.ValueToPosition(anchorY);
				}
				if (!flag5)
				{
					height = vertAxis.ValueToPosition(vertAxis.PositionToValue(y, false) + height) - y;
				}
			}
			ChartArea chartArea = null;
			if ((horizAxis != null) && (horizAxis.ChartArea != null))
			{
				chartArea = horizAxis.ChartArea;
			}
			if ((vertAxis != null) && (vertAxis.ChartArea != null))
			{
				chartArea = vertAxis.ChartArea;
			}
			if ((((chartArea != null) && chartArea.Area3DStyle.Enable3D) && (!chartArea.chartAreaIsCurcular && chartArea.requireAxes)) && chartArea.matrix3D.IsInitialized())
			{
				float areaSceneDepth = chartArea.areaSceneDepth;
				if ((this.AnchorDataPoint != null) && (this.AnchorDataPoint.series != null))
				{
					float depth = 0f;
					chartArea.GetSeriesZPositionAndDepth(this.AnchorDataPoint.series, out depth, out areaSceneDepth);
					areaSceneDepth += depth / 2f;
				}
				Point3D[] points = new Point3D[] { new Point3D((float)x, (float)y, areaSceneDepth), new Point3D((float)(x + d), (float)(y + height), areaSceneDepth), new Point3D((float)anchorX, (float)anchorY, areaSceneDepth) };
				chartArea.matrix3D.TransformPoints(points);
				x = points[0].X;
				y = points[0].Y;
				anchorX = points[2].X;
				anchorY = points[2].Y;
				if (!(this is TextAnnotation) || !this.IsSizeAlwaysRelative)
				{
					d = points[1].X - x;
					height = points[1].Y - y;
				}
			}
			if ((base.Chart != null) && base.Chart.IsDesignMode())
			{
				if (double.IsNaN(x))
				{
					x = empty.X;
					flag = false;
				}
				if (double.IsNaN(y))
				{
					y = empty.Y;
					flag = false;
				}
				if (double.IsNaN(d))
				{
					d = 20.0 * num3;
					flag = false;
				}
				if (double.IsNaN(height))
				{
					height = 20.0 * num4;
					flag = false;
				}
			}
			location = new PointF((float)x, (float)y);
			size = new SizeF((float)d, (float)height);
			anchorLocation = new PointF((float)anchorX, (float)anchorY);
			if (this.SmartLabelStyle.Enabled && (annotationGroup == null))
			{
				if ((!double.IsNaN(anchorX) && !double.IsNaN(anchorY)) && (double.IsNaN(this.X) && double.IsNaN(this.Y)))
				{
					if ((base.Chart == null) || (base.Chart.ChartPicture == null))
					{
						goto Label_0A1F;
					}
					double minMovingDistance = this.SmartLabelStyle.MinMovingDistance;
					double maxMovingDistance = this.SmartLabelStyle.MaxMovingDistance;
					PointF absolutePoint = this.GetGraphics().GetAbsolutePoint(new PointF((float)this.AnchorOffsetX, (float)this.AnchorOffsetY));
					float num21 = Math.Max(absolutePoint.X, absolutePoint.Y);
					if (num21 > 0.0)
					{
						AnnotationSmartLabelStyle smartLabelStyle = this.SmartLabelStyle;
						smartLabelStyle.MinMovingDistance += num21;
						AnnotationSmartLabelStyle style2 = this.SmartLabelStyle;
						style2.MaxMovingDistance += num21;
					}
					LabelAlignmentStyles bottom = LabelAlignmentStyles.Bottom;
					using (StringFormat format = new StringFormat())
					{
						SizeF markerSize = new SizeF((float)this.AnchorOffsetX, (float)this.AnchorOffsetY);
						PointF position = base.Chart.ChartPicture.annotationSmartLabel.AdjustSmartLabelPosition(base.Common, base.Chart.ChartPicture.ChartGraph, chartArea, this.SmartLabelStyle, location, size, format, anchorLocation, markerSize, bottom, this is CalloutAnnotation);
						this.SmartLabelStyle.MinMovingDistance = minMovingDistance;
						this.SmartLabelStyle.MaxMovingDistance = maxMovingDistance;
						if (position.IsEmpty)
						{
							location = new PointF(float.NaN, float.NaN);
						}
						else
						{
							RectangleF ef4 = base.Chart.ChartPicture.annotationSmartLabel.GetLabelPosition(base.Chart.ChartPicture.ChartGraph, position, size, format, false);
							location = ef4.Location;
						}
						goto Label_0A1F;
					}
				}
				using (StringFormat format2 = new StringFormat())
				{
					base.Chart.ChartPicture.annotationSmartLabel.AddSmartLabelPosition(base.Chart.ChartPicture.ChartGraph, location, size, format2);
				}
			}
		Label_0A1F:
			if (flag)
			{
				this.currentPositionRel = new RectangleF(location, size);
				this.currentAnchorLocationRel = new PointF(anchorLocation.X, anchorLocation.Y);
			}
		}

		internal virtual bool IsAnchorDrawn()
		{
			return false;
		}

		internal bool IsAnchorVisible()
		{
			Axis vertAxis = null;
			Axis horizAxis = null;
			this.GetAxes(ref vertAxis, ref horizAxis);
			bool inRelativeAnchorX = false;
			bool inRelativeAnchorY = false;
			double anchorX = this.AnchorX;
			double anchorY = this.AnchorY;
			this.GetAnchorLocation(ref anchorX, ref anchorY, ref inRelativeAnchorX, ref inRelativeAnchorY);
			if ((!double.IsNaN(anchorX) && !double.IsNaN(anchorY)) && (((this.AnchorDataPoint != null) || (this.AxisX != null)) || (this.AxisY != null)))
			{
				if (!inRelativeAnchorX && (horizAxis != null))
				{
					anchorX = horizAxis.ValueToPosition(anchorX);
				}
				if (!inRelativeAnchorY && (vertAxis != null))
				{
					anchorY = vertAxis.ValueToPosition(anchorY);
				}
				ChartArea chartArea = null;
				if (horizAxis != null)
				{
					chartArea = horizAxis.ChartArea;
				}
				if ((chartArea == null) && (vertAxis != null))
				{
					chartArea = vertAxis.ChartArea;
				}
				if ((((chartArea != null) && chartArea.Area3DStyle.Enable3D) && (!chartArea.chartAreaIsCurcular && chartArea.requireAxes)) && chartArea.matrix3D.IsInitialized())
				{
					float areaSceneDepth = chartArea.areaSceneDepth;
					if ((this.AnchorDataPoint != null) && (this.AnchorDataPoint.series != null))
					{
						float depth = 0f;
						chartArea.GetSeriesZPositionAndDepth(this.AnchorDataPoint.series, out depth, out areaSceneDepth);
						areaSceneDepth += depth / 2f;
					}
					Point3D[] points = new Point3D[] { new Point3D((float)anchorX, (float)anchorY, areaSceneDepth) };
					chartArea.matrix3D.TransformPoints(points);
					anchorX = points[0].X;
					anchorY = points[0].Y;
				}
				RectangleF ef = chartArea.PlotAreaPosition.ToRectangleF();
				ef.Inflate(1E-05f, 1E-05f);
				if (!ef.Contains((float)anchorX, (float)anchorY))
				{
					return false;
				}
			}
			return true;
		}

		internal bool IsVisible()
		{
			if (!this.Visible)
			{
				return false;
			}
			if (base.Chart != null)
			{
				ChartArea chartArea = null;
				if (((this.AnchorDataPoint != null) && (this.AnchorDataPoint.series != null)) && (base.Chart.ChartAreas.IndexOf(this.AnchorDataPoint.series.ChartArea) >= 0))
				{
					chartArea = base.Chart.ChartAreas[this.AnchorDataPoint.series.ChartArea];
				}
				if (((chartArea == null) && (this._anchorDataPoint2 != null)) && ((this._anchorDataPoint2.series != null) && (base.Chart.ChartAreas.IndexOf(this._anchorDataPoint2.series.ChartArea) >= 0)))
				{
					chartArea = base.Chart.ChartAreas[this._anchorDataPoint2.series.ChartArea];
				}
				if ((chartArea == null) && (this.AxisX != null))
				{
					chartArea = this.AxisX.ChartArea;
				}
				if ((chartArea == null) && (this.AxisY != null))
				{
					chartArea = this.AxisY.ChartArea;
				}
				if ((chartArea != null) && !chartArea.Visible)
				{
					return false;
				}
			}
			return true;
		}

		internal abstract void Paint(Chart chart, ChartGraphics graphics);
		internal virtual void PaintSelectionHandles(ChartGraphics chartGraphics, RectangleF rect, GraphicsPath path)
		{
			Color black = Color.Black;
			Color markerColor = Color.FromArgb(200, 0xff, 0xff, 0xff);
			MarkerStyle square = MarkerStyle.Square;
			int markerSize = 6;
			bool isSelected = this.IsSelected;
			SizeF relativeSize = chartGraphics.GetRelativeSize(new SizeF((float)markerSize, (float)markerSize));
			if (base.Common.ProcessModePaint && !base.Common.ChartPicture.isPrinting)
			{
				this.selectionRects = null;
				if (isSelected)
				{
					this.selectionRects = new RectangleF[9];
					if (this.SelectionPointsStyle == PickGold.Charting.SelectionPointsStyle.TwoPoints)
					{
						this.selectionRects[0] = new RectangleF(rect.X - (relativeSize.Width / 2f), rect.Y - (relativeSize.Height / 2f), relativeSize.Width, relativeSize.Height);
						this.selectionRects[4] = new RectangleF(rect.Right - (relativeSize.Width / 2f), rect.Bottom - (relativeSize.Height / 2f), relativeSize.Width, relativeSize.Height);
						chartGraphics.DrawMarkerRel(rect.Location, square, markerSize, markerColor, black, 1, "", Color.Empty, 0, Color.FromArgb(0x80, 0, 0, 0), RectangleF.Empty);
						chartGraphics.DrawMarkerRel(new PointF(rect.Right, rect.Bottom), square, markerSize, markerColor, black, 1, "", Color.Empty, 0, Color.FromArgb(0x80, 0, 0, 0), RectangleF.Empty);
					}
					else if (this.SelectionPointsStyle == PickGold.Charting.SelectionPointsStyle.Rectangle)
					{
						for (int i = 0; i < 8; i++)
						{
							PointF empty = PointF.Empty;
							switch (((ResizingMode)i))
							{
								case ResizingMode.TopLeftHandle:
									empty = rect.Location;
									break;

								case ResizingMode.TopHandle:
									empty = new PointF(rect.X + (rect.Width / 2f), rect.Y);
									break;

								case ResizingMode.TopRightHandle:
									empty = new PointF(rect.Right, rect.Y);
									break;

								case ResizingMode.RightHandle:
									empty = new PointF(rect.Right, rect.Y + (rect.Height / 2f));
									break;

								case ResizingMode.BottomRightHandle:
									empty = new PointF(rect.Right, rect.Bottom);
									break;

								case ResizingMode.BottomHandle:
									empty = new PointF(rect.X + (rect.Width / 2f), rect.Bottom);
									break;

								case ResizingMode.BottomLeftHandle:
									empty = new PointF(rect.X, rect.Bottom);
									break;

								case ResizingMode.LeftHandle:
									empty = new PointF(rect.X, rect.Y + (rect.Height / 2f));
									break;
							}
							this.selectionRects[i] = new RectangleF(empty.X - (relativeSize.Width / 2f), empty.Y - (relativeSize.Height / 2f), relativeSize.Width, relativeSize.Height);
							chartGraphics.DrawMarkerRel(empty, square, markerSize, markerColor, black, 1, "", Color.Empty, 0, Color.FromArgb(0x80, 0, 0, 0), RectangleF.Empty);
						}
					}
					Axis vertAxis = null;
					Axis horizAxis = null;
					this.GetAxes(ref vertAxis, ref horizAxis);
					double naN = double.NaN;
					double anchorY = double.NaN;
					bool inRelativeAnchorX = false;
					bool inRelativeAnchorY = false;
					this.GetAnchorLocation(ref naN, ref anchorY, ref inRelativeAnchorX, ref inRelativeAnchorY);
					if (!double.IsNaN(naN) && !double.IsNaN(anchorY))
					{
						if (!inRelativeAnchorX && (horizAxis != null))
						{
							naN = horizAxis.ValueToPosition(naN);
						}
						if (!inRelativeAnchorY && (vertAxis != null))
						{
							anchorY = vertAxis.ValueToPosition(anchorY);
						}
						ChartArea chartArea = null;
						if ((horizAxis != null) && (horizAxis.ChartArea != null))
						{
							chartArea = horizAxis.ChartArea;
						}
						if ((vertAxis != null) && (vertAxis.ChartArea != null))
						{
							chartArea = vertAxis.ChartArea;
						}
						if ((((chartArea != null) && chartArea.Area3DStyle.Enable3D) && (!chartArea.chartAreaIsCurcular && chartArea.requireAxes)) && chartArea.matrix3D.IsInitialized())
						{
							float areaSceneDepth = chartArea.areaSceneDepth;
							if ((this.AnchorDataPoint != null) && (this.AnchorDataPoint.series != null))
							{
								float depth = 0f;
								chartArea.GetSeriesZPositionAndDepth(this.AnchorDataPoint.series, out depth, out areaSceneDepth);
								areaSceneDepth += depth / 2f;
							}
							Point3D[] points = new Point3D[] { new Point3D((float)naN, (float)anchorY, areaSceneDepth) };
							chartArea.matrix3D.TransformPoints(points);
							naN = points[0].X;
							anchorY = points[0].Y;
						}
						this.selectionRects[8] = new RectangleF(((float)naN) - (relativeSize.Width / 2f), ((float)anchorY) - (relativeSize.Height / 2f), relativeSize.Width, relativeSize.Height);
						chartGraphics.DrawMarkerRel(new PointF((float)naN, (float)anchorY), MarkerStyle.Cross, 9, markerColor, black, 1, "", Color.Empty, 0, Color.FromArgb(0x80, 0, 0, 0), RectangleF.Empty);
					}
				}
			}
		}

		internal string ReplaceKeywords(string strOriginal)
		{
			if (this.AnchorDataPoint != null)
			{
				return this.AnchorDataPoint.ReplaceKeywords(strOriginal);
			}
			return strOriginal;
		}

		internal void ResetCurrentRelativePosition()
		{
			this.currentPositionRel = new RectangleF(float.NaN, float.NaN, float.NaN, float.NaN);
			this.currentAnchorLocationRel = new PointF(float.NaN, float.NaN);
		}

		public virtual void ResizeToContent()
		{
			RectangleF contentPosition = this.GetContentPosition();
			if (!double.IsNaN((double)contentPosition.Width))
			{
				this.Width = contentPosition.Width;
			}
			if (!double.IsNaN((double)contentPosition.Height))
			{
				this.Height = contentPosition.Height;
			}
		}

		public virtual void SendToBack()
		{
			AnnotationCollection annotations = null;
			if (base.Chart != null)
				annotations = base.Chart.Annotations;
			var annotationGroup = this.AnnotationGroup;
			if (annotationGroup != null)
				annotations = annotationGroup.Annotations;
			if (annotations != null)
			{
				var item = annotations.FindByName(this.Name);
				if (item != null)
				{
					annotations.Remove(item);
					annotations.Insert(0, item);
				}
			}
		}

		public void SetAnchor(DataPoint dataPoint)
		{
			this.SetAnchor(dataPoint, null);
		}

		public void SetAnchor(DataPoint dataPoint1, DataPoint dataPoint2)
		{
			this.X = double.NaN;
			this.Y = double.NaN;
			this.AnchorX = double.NaN;
			this.AnchorY = double.NaN;
			this.AnchorDataPoint = dataPoint1;
			Axis vertAxis = null;
			Axis horizAxis = null;
			this.GetAxes(ref vertAxis, ref horizAxis);
			if ((dataPoint2 != null) && (dataPoint1 != null))
			{
				this._anchorDataPoint2 = dataPoint2;
			}
			this.Invalidate();
		}

		internal void SetPositionRelative(RectangleF position, PointF anchorPoint, bool userInput)
		{
			double x = position.X;
			double y = position.Y;
			double right = position.Right;
			double bottom = position.Bottom;
			double width = position.Width;
			double height = position.Height;
			double anchorX = anchorPoint.X;
			double anchorY = anchorPoint.Y;
			this.currentPositionRel = new RectangleF(position.Location, position.Size);
			this.currentAnchorLocationRel = new PointF(anchorPoint.X, anchorPoint.Y);
			new RectangleF(0f, 0f, 100f, 100f);
			if ((this.ClipToChartArea.Length > 0) && (this.ClipToChartArea != "NotSet"))
			{
				int index = base.Chart.ChartAreas.IndexOf(this.ClipToChartArea);
				if (index >= 0)
				{
					base.Chart.ChartAreas[index].PlotAreaPosition.ToRectangleF();
				}
			}
			Axis vertAxis = null;
			Axis horizAxis = null;
			this.GetAxes(ref vertAxis, ref horizAxis);
			ChartArea chartArea = null;
			if ((horizAxis != null) && (horizAxis.ChartArea != null))
			{
				chartArea = horizAxis.ChartArea;
			}
			if ((vertAxis != null) && (vertAxis.ChartArea != null))
			{
				chartArea = vertAxis.ChartArea;
			}
			if ((chartArea != null) && chartArea.Area3DStyle.Enable3D)
			{
				if (this.AnchorDataPoint != null)
				{
					bool inRelativeAnchorX = true;
					bool inRelativeAnchorY = true;
					this.GetAnchorLocation(ref anchorX, ref anchorY, ref inRelativeAnchorX, ref inRelativeAnchorY);
					this.currentAnchorLocationRel = new PointF((float)anchorX, (float)anchorY);
				}
				this.AnchorDataPoint = null;
				this.AxisX = null;
				this.AxisY = null;
				horizAxis = null;
				vertAxis = null;
			}
			if (horizAxis != null)
			{
				x = horizAxis.PositionToValue(x, false);
				if (!double.IsNaN(anchorX))
				{
					anchorX = horizAxis.PositionToValue(anchorX, false);
				}
				if (horizAxis.IsLogarithmic)
				{
					x = Math.Pow(horizAxis.logarithmBase, x);
					if (!double.IsNaN(anchorX))
					{
						anchorX = Math.Pow(horizAxis.logarithmBase, anchorX);
					}
				}
				if (!this.IsSizeAlwaysRelative)
				{
					if ((float.IsNaN(position.Right) && !float.IsNaN(position.Width)) && !float.IsNaN(anchorPoint.X))
					{
						right = horizAxis.PositionToValue((double)(anchorPoint.X + position.Width), false);
						if (horizAxis.IsLogarithmic)
						{
							right = Math.Pow(horizAxis.logarithmBase, right);
						}
						width = right - anchorX;
					}
					else
					{
						right = horizAxis.PositionToValue((double)position.Right, false);
						if (horizAxis.IsLogarithmic)
						{
							right = Math.Pow(horizAxis.logarithmBase, right);
						}
						width = right - x;
					}
				}
			}
			if (vertAxis != null)
			{
				y = vertAxis.PositionToValue(y, false);
				if (!double.IsNaN(anchorY))
				{
					anchorY = vertAxis.PositionToValue(anchorY, false);
				}
				if (vertAxis.IsLogarithmic)
				{
					y = Math.Pow(vertAxis.logarithmBase, y);
					if (!double.IsNaN(anchorY))
					{
						anchorY = Math.Pow(vertAxis.logarithmBase, anchorY);
					}
				}
				if (!this.IsSizeAlwaysRelative)
				{
					if ((float.IsNaN(position.Bottom) && !float.IsNaN(position.Height)) && !float.IsNaN(anchorPoint.Y))
					{
						bottom = vertAxis.PositionToValue((double)(anchorPoint.Y + position.Height), false);
						if (vertAxis.IsLogarithmic)
						{
							bottom = Math.Pow(vertAxis.logarithmBase, bottom);
						}
						height = bottom - anchorY;
					}
					else
					{
						bottom = vertAxis.PositionToValue((double)position.Bottom, false);
						if (vertAxis.IsLogarithmic)
						{
							bottom = Math.Pow(vertAxis.logarithmBase, bottom);
						}
						height = bottom - y;
					}
				}
			}
			this.X = x;
			this.Y = y;
			this.Width = width;
			this.Height = height;
			this.AnchorX = anchorX;
			this.AnchorY = anchorY;
			this.Invalidate();
		}

		[SRCategory("CategoryAttributeAppearance")]
		[SRDescription("DescriptionAttributeAlignment")]
		[DefaultValue(typeof(ContentAlignment), "MiddleCenter")]
		public virtual ContentAlignment Alignment
		{
			get
			{
				return this._alignment;
			}
			set
			{
				this._alignment = value;
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeAnchor")]
		[SRDescription("DescriptionAttributeAnchorAlignment")]
		[DefaultValue(typeof(ContentAlignment), "BottomCenter")]
		public virtual ContentAlignment AnchorAlignment
		{
			get
			{
				return this.anchorAlignment;
			}
			set
			{
				this.anchorAlignment = value;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[SRDescription("DescriptionAttributeAnchorDataPoint")]
		[SRCategory("CategoryAttributeAnchor")]
		[DefaultValue((string)null)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		[SerializationVisibility(SerializationVisibility.Hidden)]
		[Editor(typeof(AnchorPointUITypeEditor), typeof(UITypeEditor))]
		[TypeConverter(typeof(AnchorPointValueConverter))]
		public virtual DataPoint AnchorDataPoint
		{
			get
			{
				if ((this._anchorDataPoint == null) && (this._anchorDataPointName.Length > 0))
				{
					this._anchorDataPoint = this.GetDataPointByName(this._anchorDataPointName);
				}
				return this._anchorDataPoint;
			}
			set
			{
				this._anchorDataPoint = value;
				this._anchorDataPointName = string.Empty;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeAnchor")]
		[SRDescription("DescriptionAttributeAnchorDataPointName")]
		[Browsable(false)]
		[Bindable(false)]
		[EditorBrowsable(EditorBrowsableState.Never)]
		[DefaultValue("")]
		public virtual string AnchorDataPointName
		{
			get
			{
				if ((this._anchorDataPointName.Length == 0) && (this._anchorDataPoint != null))
				{
					this._anchorDataPointName = this.GetDataPointName(this._anchorDataPoint);
				}
				return this._anchorDataPointName;
			}
			set
			{
				this._anchorDataPointName = value;
				this._anchorDataPoint = null;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[RefreshProperties(RefreshProperties.All)]
		[SRCategory("CategoryAttributeAnchor")]
		[DefaultValue((double)0.0)]
		[SRDescription("DescriptionAttributeAnchorOffsetX3")]
		public virtual double AnchorOffsetX
		{
			get
			{
				return this.anchorOffsetX;
			}
			set
			{
				if ((value > 100.0) || (value < -100.0))
				{
					throw new ArgumentOutOfRangeException("value", SR.ExceptionAnnotationAnchorOffsetInvalid);
				}
				this.anchorOffsetX = value;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[SRDescription("DescriptionAttributeAnchorOffsetY3")]
		[SRCategory("CategoryAttributeAnchor")]
		[DefaultValue((double)0.0)]
		[RefreshProperties(RefreshProperties.All)]
		public virtual double AnchorOffsetY
		{
			get
			{
				return this.anchorOffsetY;
			}
			set
			{
				if ((value > 100.0) || (value < -100.0))
				{
					throw new ArgumentOutOfRangeException("value", SR.ExceptionAnnotationAnchorOffsetInvalid);
				}
				this.anchorOffsetY = value;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeAnchor")]
		[DefaultValue(double.NaN)]
		[SRDescription("DescriptionAttributeAnchorX")]
		[RefreshProperties(RefreshProperties.All)]
		[TypeConverter(typeof(DoubleNanValueConverter))]
		public virtual double AnchorX
		{
			get
			{
				return this._anchorX;
			}
			set
			{
				this._anchorX = value;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[SRDescription("DescriptionAttributeAnchorY")]
		[SRCategory("CategoryAttributeAnchor")]
		[DefaultValue(double.NaN)]
		[RefreshProperties(RefreshProperties.All)]
		[TypeConverter(typeof(DoubleNanValueConverter))]
		public virtual double AnchorY
		{
			get
			{
				return this._anchorY;
			}
			set
			{
				this._anchorY = value;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[Browsable(false)]
		[SerializationVisibility(SerializationVisibility.Hidden)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public AnnotationGroup AnnotationGroup
		{
			get
			{
				return this.annotationGroup;
			}
		}

		[SRDescription("DescriptionAttributeAnnotation_AnnotationType")]
		[Browsable(false)]
		[SerializationVisibility(SerializationVisibility.Hidden)]
		[Bindable(true)]
		[SRCategory("CategoryAttributeMisc")]
		[EditorBrowsable(EditorBrowsableState.Never)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public abstract string AnnotationType { get; }

		[Editor(typeof(AnnotationAxisUITypeEditor), typeof(UITypeEditor))]
		[TypeConverter(typeof(AnnotationAxisValueConverter))]
		[DefaultValue((string)null)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		[SerializationVisibility(SerializationVisibility.Hidden)]
		[SRDescription("DescriptionAttributeAxisX")]
		[SRCategory("CategoryAttributeAnchorAxes")]
		public virtual Axis AxisX
		{
			get
			{
				if ((this._axisX == null) && (this._axisXName.Length > 0))
				{
					this._axisX = this.GetAxisByName(this._axisXName);
				}
				return this._axisX;
			}
			set
			{
				this._axisX = value;
				this._axisXName = string.Empty;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[DefaultValue("")]
		[SRCategory("CategoryAttributeAnchorAxes")]
		[Browsable(false)]
		[Bindable(false)]
		[EditorBrowsable(EditorBrowsableState.Never)]
		[SRDescription("DescriptionAttributeAxisXName")]
		public virtual string AxisXName
		{
			get
			{
				if ((this._axisXName.Length == 0) && (this._axisX != null))
				{
					this._axisXName = this.GetAxisName(this._axisX);
				}
				return this._axisXName;
			}
			set
			{
				this._axisXName = value;
				this._axisX = null;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		[SRCategory("CategoryAttributeAnchorAxes")]
		[DefaultValue((string)null)]
		[TypeConverter(typeof(AnnotationAxisValueConverter))]
		[SerializationVisibility(SerializationVisibility.Hidden)]
		[SRDescription("DescriptionAttributeAxisY")]
		[Editor(typeof(AnnotationAxisUITypeEditor), typeof(UITypeEditor))]
		public virtual Axis AxisY
		{
			get
			{
				if ((this._axisY == null) && (this._axisYName.Length > 0))
				{
					this._axisY = this.GetAxisByName(this._axisYName);
				}
				return this._axisY;
			}
			set
			{
				this._axisY = value;
				this._axisYName = string.Empty;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[Bindable(false)]
		[SRCategory("CategoryAttributeAnchorAxes")]
		[Browsable(false)]
		[SerializationVisibility(SerializationVisibility.Hidden)]
		[EditorBrowsable(EditorBrowsableState.Never)]
		[DefaultValue("")]
		[SRDescription("DescriptionAttributeAxisYName")]
		public virtual string AxisYName
		{
			get
			{
				return string.Empty;
			}
			set
			{
				this.YAxisName = value;
			}
		}

		[TypeConverter(typeof(ColorConverter))]
		[SRCategory("CategoryAttributeAppearance")]
		[DefaultValue(typeof(Color), "")]
		[SRDescription("DescriptionAttributeBackColor")]
		[NotifyParentProperty(true)]
		[Editor(typeof(ChartColorEditor), typeof(UITypeEditor))]
		public virtual Color BackColor
		{
			get
			{
				return this._backColor;
			}
			set
			{
				this._backColor = value;
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeAppearance"), Editor(typeof(GradientEditor), typeof(UITypeEditor)), DefaultValue(0), NotifyParentProperty(true), SRDescription("DescriptionAttributeBackGradientStyle")]
		public virtual GradientStyle BackGradientStyle
		{
			get
			{
				return this._backGradientStyle;
			}
			set
			{
				this._backGradientStyle = value;
				this.Invalidate();
			}
		}

		[DefaultValue(0), SRCategory("CategoryAttributeAppearance"), Editor(typeof(HatchStyleEditor), typeof(UITypeEditor)), NotifyParentProperty(true), SRDescription("DescriptionAttributeBackHatchStyle")]
		public virtual ChartHatchStyle BackHatchStyle
		{
			get
			{
				return this._backHatchStyle;
			}
			set
			{
				this._backHatchStyle = value;
				this.Invalidate();
			}
		}

		[TypeConverter(typeof(ColorConverter)), SRCategory("CategoryAttributeAppearance"), DefaultValue(typeof(Color), ""), NotifyParentProperty(true), SRDescription("DescriptionAttributeBackSecondaryColor"), Editor(typeof(ChartColorEditor), typeof(UITypeEditor))]
		public virtual Color BackSecondaryColor
		{
			get
			{
				return this._backSecondaryColor;
			}
			set
			{
				this._backSecondaryColor = value;
				this.Invalidate();
			}
		}

		[RefreshProperties(RefreshProperties.All), SerializationVisibility(SerializationVisibility.Hidden), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), SRDescription("DescriptionAttributeBottom"), DefaultValue(double.NaN), TypeConverter(typeof(DoubleNanValueConverter)), SRCategory("CategoryAttributePosition")]
		public virtual double Bottom
		{
			get
			{
				return (this._y + this._height);
			}
			set
			{
				this._height = value - this._y;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[DefaultValue("NotSet"), TypeConverter(typeof(LegendAreaNameConverter)), SRCategory("CategoryAttributeMisc"), SRDescription("DescriptionAttributeAnnotationClipToChartArea")]
		public virtual string ClipToChartArea
		{
			get
			{
				return this._clipToChartArea;
			}
			set
			{
				if (value != this._clipToChartArea)
				{
					if (string.IsNullOrEmpty(value))
					{
						this._clipToChartArea = "NotSet";
					}
					else
					{
						if ((base.Chart != null) && (base.Chart.ChartAreas != null))
						{
							base.Chart.ChartAreas.VerifyNameReference(value);
						}
						this._clipToChartArea = value;
					}
					this.Invalidate();
				}
			}
		}

		[SRCategory("CategoryAttributeAppearance"), SRDescription("DescriptionAttributeTextFont"), DefaultValue(typeof(System.Drawing.Font), "Microsoft Sans Serif, 8pt")]
		public virtual System.Drawing.Font Font
		{
			get
			{
				return this._textFont;
			}
			set
			{
				this._textFont = value;
				this.Invalidate();
			}
		}

		[Editor(typeof(ChartColorEditor), typeof(UITypeEditor)), DefaultValue(typeof(Color), "Black"), SRDescription("DescriptionAttributeForeColor"), TypeConverter(typeof(ColorConverter)), SRCategory("CategoryAttributeAppearance")]
		public virtual Color ForeColor
		{
			get
			{
				return this._foreColor;
			}
			set
			{
				this._foreColor = value;
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributePosition"), DefaultValue(double.NaN), SRDescription("DescriptionAttributeAnnotationHeight"), RefreshProperties(RefreshProperties.All), TypeConverter(typeof(DoubleNanValueConverter))]
		public virtual double Height
		{
			get
			{
				return this._height;
			}
			set
			{
				if ((value < -WidthHightLimit) || (value > WidthHightLimit))
				{
					double num = -WidthHightLimit;
					throw new ArgumentException(SR.ExceptionValueMustBeInRange("Height", num.ToString(CultureInfo.CurrentCulture), WidthHightLimit.ToString(CultureInfo.CurrentCulture)));
				}
				this._height = value;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeAppearance"), Browsable(false), SRDescription("DescriptionAttributeSelected"), DefaultValue(false)]
		public virtual bool IsSelected
		{
			get
			{
				return this._isSelected;
			}
			set
			{
				this._isSelected = value;
				this.Invalidate();
			}
		}

		[DefaultValue(true), SRDescription("DescriptionAttributeSizeAlwaysRelative"), SRCategory("CategoryAttributePosition")]
		public virtual bool IsSizeAlwaysRelative
		{
			get
			{
				return this._isSizeAlwaysRelative;
			}
			set
			{
				this._isSizeAlwaysRelative = value;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[DefaultValue(typeof(Color), "Black"), SRCategory("CategoryAttributeAppearance"), SRDescription("DescriptionAttributeLineColor"), TypeConverter(typeof(ColorConverter)), Editor(typeof(ChartColorEditor), typeof(UITypeEditor))]
		public virtual Color LineColor
		{
			get
			{
				return this.lineColor;
			}
			set
			{
				this.lineColor = value;
				this.Invalidate();
			}
		}

		[SRDescription("DescriptionAttributeLineDashStyle"), SRCategory("CategoryAttributeAppearance"), DefaultValue(5)]
		public virtual ChartDashStyle LineDashStyle
		{
			get
			{
				return this._lineDashStyle;
			}
			set
			{
				this._lineDashStyle = value;
				this.Invalidate();
			}
		}

		[DefaultValue(1), SRDescription("DescriptionAttributeLineWidth"), SRCategory("CategoryAttributeAppearance")]
		public virtual int LineWidth
		{
			get
			{
				return this._lineWidth;
			}
			set
			{
				if (value < 0)
				{
					throw new ArgumentOutOfRangeException("value", SR.ExceptionAnnotationLineWidthIsNegative);
				}
				this._lineWidth = value;
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeMisc"), DefaultValue(""), SRDescription("DescriptionAttributeMapAreaAttributes")]
		public virtual string MapAreaAttributes
		{
			get
			{
				return this._mapAreaAttributes;
			}
			set
			{
				this._mapAreaAttributes = value;
			}
		}

		[ParenthesizePropertyName(true), SRCategory("CategoryAttributeMisc"), Bindable(true), SRDescription("DescriptionAttributeName4")]
		public override string Name
		{
			get
			{
				return base.Name;
			}
			set
			{
				base.Name = value;
			}
		}

		[DefaultValue(""), SRDescription("DescriptionAttributePostBackValue"), SRCategory("CategoryAttributeMapArea")]
		public string PostBackValue
		{
			get
			{
				return this._postbackValue;
			}
			set
			{
				this._postbackValue = value;
			}
		}

		[Browsable(false), SRCategory("CategoryAttributePosition"), SRDescription("DescriptionAttributeRight3"), RefreshProperties(RefreshProperties.All), SerializationVisibility(SerializationVisibility.Hidden), DefaultValue(double.NaN), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), TypeConverter(typeof(DoubleNanValueConverter))]
		public virtual double Right
		{
			get
			{
				return (this._x + this._width);
			}
			set
			{
				this._width = value - this._x;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[EditorBrowsable(EditorBrowsableState.Never), ParenthesizePropertyName(true), Browsable(false), SRDescription("DescriptionAttributeSelectionPointsStyle"), DefaultValue(1), SRCategory("CategoryAttributeAppearance"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), SerializationVisibility(SerializationVisibility.Hidden)]
		internal virtual SelectionPointsStyle SelectionPointsStyle
		{
			get
			{
				return SelectionPointsStyle.Rectangle;
			}
		}

		[DefaultValue(typeof(Color), "128,0,0,0")]
		[SRCategory("CategoryAttributeAppearance")]
		[SRDescription("DescriptionAttributeShadowColor")]
		[TypeConverter(typeof(ColorConverter))]
		[Editor(typeof(ChartColorEditor), typeof(UITypeEditor))]
		public virtual Color ShadowColor
		{
			get
			{
				return this._shadowColor;
			}
			set
			{
				this._shadowColor = value;
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeAppearance"), DefaultValue(0), SRDescription("DescriptionAttributeShadowOffset")]
		public virtual int ShadowOffset
		{
			get
			{
				return this._shadowOffset;
			}
			set
			{
				this._shadowOffset = value;
				this.Invalidate();
			}
		}

		[Bindable(true), SRDescription("DescriptionAttributeSmartLabels"), SRCategory("CategoryAttributeMisc"), PersistenceMode(PersistenceMode.InnerProperty), Browsable(true)]
		public AnnotationSmartLabelStyle SmartLabelStyle
		{
			get
			{
				if (this._smartLabelStyle == null)
				{
					this._smartLabelStyle = new AnnotationSmartLabelStyle(this);
				}
				return this._smartLabelStyle;
			}
			set
			{
				value.chartElement = this;
				this._smartLabelStyle = value;
				this.Invalidate();
			}
		}

		[SRDescription("DescriptionAttributeTextStyle")]
		[DefaultValue(typeof(TextStyle), "Default")]
		[SRCategory("CategoryAttributeAppearance")]
		public virtual TextStyle TextStyle
		{
			get
			{
				return this._textStyle;
			}
			set
			{
				this._textStyle = value;
				this.Invalidate();
			}
		}

		[SRDescription("DescriptionAttributeToolTip")]
		[SRCategory("CategoryAttributeMisc")]
		[DefaultValue("")]
		public virtual string ToolTip
		{
			get
			{
				return this._tooltip;
			}
			set
			{
				this._tooltip = value;
			}
		}

		[SRCategory("CategoryAttributeMisc"), DefaultValue(""), SRDescription("DescriptionAttributeUrl")]
		public virtual string Url
		{
			get
			{
				return this._url;
			}
			set
			{
				this._url = value;
			}
		}

		[SRDescription("DescriptionAttributeVisible"), ParenthesizePropertyName(true), SRCategory("CategoryAttributeAppearance"), DefaultValue(true)]
		public virtual bool Visible
		{
			get
			{
				return this._visible;
			}
			set
			{
				this._visible = value;
				this.Invalidate();
			}
		}

		[RefreshProperties(RefreshProperties.All), DefaultValue(double.NaN), SRDescription("DescriptionAttributeAnnotationWidth"), SRCategory("CategoryAttributePosition"), TypeConverter(typeof(DoubleNanValueConverter))]
		public virtual double Width
		{
			get
			{
				return this._width;
			}
			set
			{
				if ((value < -WidthHightLimit) || (value > WidthHightLimit))
				{
					double num = -WidthHightLimit;
					throw new ArgumentException(SR.ExceptionValueMustBeInRange("Width", num.ToString(CultureInfo.CurrentCulture), WidthHightLimit.ToString(CultureInfo.CurrentCulture)));
				}
				this._width = value;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[TypeConverter(typeof(DoubleNanValueConverter)), RefreshProperties(RefreshProperties.All), SRCategory("CategoryAttributePosition"), DefaultValue(double.NaN), SRDescription("DescriptionAttributeAnnotationBaseX")]
		public virtual double X
		{
			get
			{
				return this._x;
			}
			set
			{
				this._x = value;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[SRDescription("DescriptionAttributeAnnotationBaseY"), DefaultValue(double.NaN), RefreshProperties(RefreshProperties.All), TypeConverter(typeof(DoubleNanValueConverter)), SRCategory("CategoryAttributePosition")]
		public virtual double Y
		{
			get
			{
				return this._y;
			}
			set
			{
				this._y = value;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeAnchorAxes"), SRDescription("DescriptionAttributeAxisYName"), Browsable(false), Bindable(false), EditorBrowsable(EditorBrowsableState.Never), DefaultValue("")]
		public virtual string YAxisName
		{
			get
			{
				if ((this._axisYName.Length == 0) && (this._axisY != null))
				{
					this._axisYName = this.GetAxisName(this._axisY);
				}
				return this._axisYName;
			}
			set
			{
				this._axisYName = value;
				this._axisY = null;
				this.ResetCurrentRelativePosition();
				this.Invalidate();
			}
		}
	}
}

